<?php
class service_user{
	public function getByID($userID){
		$dao = new DaoUser();
		$user = $dao->getOne(" id='$userID'");
		if(empty($user)){
			return array();
		}
		return $user;
	}
	public function update($wID,$params){
		if(empty($params)||$wID=='') return false;
		$dao = new DaoUser();
		$user = $dao->getOne(" wID ='$wID'");
		if(empty($user)){
			$params['wID'] = $wID;
			$id = $dao->insert($params);
		}else{
			$dao->update(" wID='$wID'",$params);
			$id = $user['id'];
		}
		return $id;
	}
	public function isHaveByWID($wID){
		if($wID=='') return false;
		$dao = new DaoUser();
		$user = $dao->getOne(" wID='$wID'");
		if(empty($user)){
			return false;
		}else{
			return true;
		}
	}
	public function getByWID($wID){
		$dao = new DaoUser();
		$user = $dao->getOne(" wID='$wID'");
		if(empty($user)) return array();
		return $user;
	}
	public function getAll(){
		$userDao = new DaoUser();
		$userlist = $userDao->getAll();
		return $userlist;
	}
	public function getNameById($id){
		$userDao = new DaoUser();
		$user = $userDao->getOne("id = ".$id);
		return $user['name'];
	}
	public function isHaveProducts($userID){
		$dao = new DaoProduct();
		$count = $dao->getCount("userID='$userID'");
		if($count) return true;
		return false;
	}
}
?>
